home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / lang / SmallEiffel.lha / SmallEiffel / lib_rand / demo3.e < prev    next >
Text File  |  1998-12-22  |  2KB  |  64 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  10. --                       http://www.loria.fr/SmallEiffel
  11. --
  12. class DEMO3
  13.  
  14. creation make 
  15.  
  16. feature
  17.  
  18.    make is
  19.       local
  20.      rand: GEN_RAND;
  21.      seed, count: INTEGER;
  22.       do
  23.      if argument_count < 2 then
  24.         io.put_string(
  25.         "Usage: demo <seed> <count> [min_stand|std_rand]%N%
  26.         %Examples :%N%
  27.         %   demo 234 10 %N%
  28.         %   demo 234 10 std_rand%N%
  29.         %   demo 234 100 min_stand%N");
  30.         die_with_code(exit_failure_code);
  31.      end;
  32.      seed := argument(1).to_integer;
  33.      count := argument(2).to_integer;
  34.      if argument_count > 2 then
  35.         if argument(3).same_as("MIN_STAND") then
  36.            !MIN_STAND!rand.with_seed(seed);
  37.            io.put_string("Using MIN_STAND%N.");
  38.         else
  39.            !STD_RAND!rand.with_seed(seed);
  40.            io.put_string("Using STD_RAND%N.");
  41.         end;
  42.      else
  43.         !STD_RAND!rand.with_seed(seed);
  44.         io.put_string("Using default STD_RAND%N.");
  45.      end;
  46.      from
  47.      until
  48.         count = 0
  49.      loop
  50.         rand.next;
  51.         io.put_double(rand.last_double);
  52.         count := count - 1;
  53.         io.put_string("%N");
  54.      end;
  55.       end;
  56.  
  57.    generators: ARRAY[STRING] is 
  58.       once
  59.      Result := <<"MIN_STAND","STD_RAN">>;
  60.       end;
  61.  
  62. end -- DEMO3
  63.  
  64.